import {ModalForm, ProFormDigit, ProFormText} from '@ant-design/pro-components';


export interface FormValueType extends Partial<API.Dictionary> {
  target?: string;
  template?: string;
  type?: string;
  time?: string;
  frequency?: string;
}


export interface EditFormProps {
  onOpenChange: (flag?: boolean, formVals?: FormValueType) => void;
  onSubmit: (values: FormValueType) => Promise<void>;
  editModalVisible: boolean;
  values: Partial<API.Dictionary>;
}


export default (props:EditFormProps) => {
  return (
      <ModalForm
        title="编辑字典"
        open={props.editModalVisible}
        onOpenChange={props.onOpenChange}
        onFinish={props.onSubmit}
        initialValues={{
          id: props.values.id,
          name: props.values.name,
          code: props.values.code,
          sort: props.values.sort,
          val: props.values.val,
        }}
    >
      <ProFormText
        width="md"
        name="id"
        label="Id"
        hidden={true}
        disabled={true}
      />
      <ProFormText
        name="code"
        width="md"
        label="编码"
        disabled={true}
        rules={[
          { required: true, message: '请输入编码！' },
        ]}
      />
      <ProFormText
        width="md"
        name="name"
        label="名称"
        rules={[{ required: true, message: '请输入名称！' }]}
      />
        <ProFormText
        width="md"
        name="val"
        label="自定义值"
        rules={[{ required: true, message: '请输入自定义值！' }]}
      />
      <ProFormDigit
        width="md"
        name="sort"
        label="排序"
      />
    </ModalForm>
  );
};
